package com.greenlife.common.result;

import com.greenlife.commom.ToString;
import com.greenlife.common.enums.BaseResultCodeEnum;

/**
 * 公用结果对象
 * 
 * @author peitong.xue
 * @version 1.0
 * @since 1.0 2015年11月21日 下午11:44:09
 */
public class CommonResult extends ToString {

    /** serialVersionUID */
    private static final long serialVersionUID = 6969395970079946617L;

    /** 是否成功，需先判断该值是否为true，只有为ture时方可继续正常的后续业务处理 */
    public boolean            success          = false;

    /** 返回code */
    public String             resultCode;

    /** 结果描述 **/
    public String             resultMsg;

    /**
     * 默认构造
     */
    public CommonResult() {
    }

    /**
     * 构造函数
     * 
     * @param success       是否成功
     * @param resultCode    结果码
     * @param resultMsg     结果描述
     */

    public CommonResult(boolean success, String resultCode, String resultMsg) {
        this.success = success;
        this.resultCode = resultCode;
        this.resultMsg = resultMsg;
    }
    
    /**
     * @author TKC
     * 新增的构造函数
     * @since 1.0 2015年12月18日 下午11:46:51
     * @param resultCodeEnum 结果编码
     */
    public CommonResult(BaseResultCodeEnum baseResultCodeEnum) {
        setSuccess(baseResultCodeEnum == BaseResultCodeEnum.ERR_CODE_200);
        setResultCode(baseResultCodeEnum.getCode());
        setResultMsg(baseResultCodeEnum.getMsg());
    }
    
    
    /**
     * Getter method for property <tt>success</tt>.
     * 
     * @return property value of success
     */
    public boolean isSuccess() {
        return success;
    }

    /**
     * Setter method for property <tt>success</tt>.
     * 
     * @param success value to be assigned to property success
     */
    public void setSuccess(boolean success) {
        this.success = success;
    }

    /**
     * Getter method for property <tt>resultCode</tt>.
     * 
     * @return property value of resultCode
     */
    public String getResultCode() {
        return resultCode;
    }

    /**
     * Setter method for property <tt>resultCode</tt>.
     * 
     * @param resultCode value to be assigned to property resultCode
     */
    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    /**
     * Getter method for property <tt>resultMsg</tt>.
     * 
     * @return property value of resultMsg
     */
    public String getResultMsg() {
        return resultMsg;
    }

    /**
     * Setter method for property <tt>resultMsg</tt>.
     * 
     * @param resultMsg value to be assigned to property resultMsg
     */
    public void setResultMsg(String resultMsg) {
        this.resultMsg = resultMsg;
    }

}
